<template>
  <div>
    <div class="top">
      <p class="right">
        服务热线 1010-9898
        <br />
        服务时间 9.00-22.00
      </p>
      <a href="">
        <img
          onerror="nofind()"
          src="//r01.uzaicdn.com/content/store/images/user/logo.png?imageView2/2/w/254/h/46"
          class="logo"
        />
      </a>
    </div>
    <div class="main">
      <div class="main_logo">
        <div class="main_logo_top">
          <div class="li active blue">修改密码</div>
        </div>
        <div id="app">
          <el-form
            :model="ruleForm"
            status-icon
            :rules="rules"
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
          >
            <el-form-item label="输入密码" prop="pass">
              <el-input
                type="password"
                v-model="ruleForm.pass"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item label="确认密码" prop="checkPass">
              <el-input
                type="password"
                v-model="ruleForm.checkPass"
                autocomplete="off"
              ></el-input>
            </el-form-item>
            <el-form-item label="输入年龄" prop="age">
              <el-input v-model.number="ruleForm.age"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="submitForm('ruleForm')"
                >确定</el-button
              >
              <el-button @click="resetForm('ruleForm')">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
    <div class="foot">
      <a href="">众信旅游</a>
      <a href="">众信历程</a>
      <a href="">众信品牌</a>
      <a href="">营业网点</a>
      <a href="">诚聘英才</a>
      <a href="">商务合作</a>
      <br />
      <a>Copyright©2005-2018 Uzai.com&nbsp;&nbsp;&nbsp;&nbsp;</a>
      <a>许可证编号:L-TJ-CJ00059&nbsp;&nbsp;&nbsp;&nbsp;</a>
      <a>津ICP备18003064号&nbsp;&nbsp;&nbsp;&nbsp;</a>
      <a>悠哉呼叫中心来电显示号码为：10086110</a>
    </div>
  </div>
</template>
<script src="//unpkg.com/vue@2/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.15.8/lib/index.js"></script>

<script>
var Main = {
  data() {
    var checkAge = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("年龄不能为空"));
      }
      setTimeout(() => {
        if (!Number.isInteger(value)) {
          callback(new Error("请输入数字值"));
        } else {
          if (value < 18) {
            callback(new Error("必须年满18岁"));
          } else {
            callback();
          }
        }
      }, 1000);
    };
    var validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.ruleForm.checkPass !== "") {
          this.$refs.ruleForm.validateField("checkPass");
        }
        callback();
      }
    };
    var validatePass2 = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请再次输入密码"));
      } else if (value !== this.ruleForm.pass) {
        callback(new Error("两次输入密码不一致!"));
      } else {
        callback();
      }
    };
    return {
      ruleForm: {
        pass: "",
        checkPass: "",
        age: "",
      },
      rules: {
        pass: [{ validator: validatePass, trigger: "blur" }],
        checkPass: [{ validator: validatePass2, trigger: "blur" }],
        age: [{ validator: checkAge, trigger: "blur" }],
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("修改成功!");
          window.location.href =
            "http://127.0.0.1:8848/%E7%99%BB%E5%BD%95/%E7%99%BB%E5%BD%95.html";
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
var Ctor = Vue.extend(Main);
new Ctor().$mount("#app");
</script>

<style lang="scss" scoped>
@import url("//unpkg.com/element-ui@2.15.8/lib/theme-chalk/index.css");
.top {
  width: 1000px;
  margin: auto;
  height: 100px;
}
.top p.right {
  float: right;
  margin-right: 10px;
  margin-top: 40px;
  color: chocolate;
}
a {
  text-decoration: none;
  color: #000;
}
.top img.logo {
  float: left;
  margin-left: 10px;
  margin-top: 31px;
}
.main {
  position: relative;
  height: 540px;
  background: url(//r.uzaicdn.com/content/store/images/user/main.jpg) no-repeat
    center;
}
.main_logo {
  width: 460px;
  background: #fff;
  border-radius: 10px;
  position: absolute;
  left: 50%;
  margin-left: 45px;
  top: 128px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.25);
  padding: 25px 32px;
  padding-right: 0;
  padding-bottom: 10px;
}
.main_logo_top {
  overflow: hidden;
}
.foot {
  margin-top: 30px;
  padding-bottom: 30px;
  text-align: center;
}
.foot a:hover {
  color: skyblue;
  font-size: 16px;
}
.foot p:hover {
  color: skyblue;
}
.foot a {
  font-size: 14px;
  color: #666;
  padding: 0 3px;
  line-height: 30px;
}
a {
  text-decoration: none;
  color: #000;
}
.foot p {
  color: #999;
  font-size: 12px;
  line-height: 17px;
}
.el-form-item__content {
  line-height: 40px;
  position: relative;
  font-size: 14px;
  margin-right: 64px;
}
.main_logo_top {
  overflow: hidden;
}
.main_logo_top .li.blue {
  padding-bottom: 10px;
  background: url(//r.uzaicdn.com/content/store/images/user/nav.png) no-repeat
    bottom center;
}
.main_logo_top .li.blue:hover {
  color: blue;
}
.main_logo_top .li.active {
  font-size: 18px;
}
.main_logo_top .li {
  color: #000;
  float: left;
  line-height: 24px;
  cursor: pointer;
  margin-left: 29px;
  margin-bottom: 10px;
}
</style>
